package com.ylkj.patient.ui.activities;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.examination.mlib.constants.ARouterConstants;
import com.examination.mlib.constants.KitArouterConstants;
import com.examination.mlib.constants.UserInfoConstants;
import com.users.rn.rncommon.util.RNDebugUtils;
import com.yilijk.base.utils.ClickUtils;
import com.ylkj.patient.R;
import com.ylkj.patient.utils.AppReactUtils;

@Route(path = ARouterConstants.DebugRnActivity)
public class DebugRnActivity extends AppCompatActivity {

    private EditText no;
    private EditText ip;
    TextView pageName;
    @Autowired
    MainActivity mainActivity;
    private View webBackView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_debug_rn);
        TextView titleName = (TextView) findViewById(R.id.webviewtitle);
        titleName.setText("react-native setting debug");
        ip = (EditText)findViewById(R.id.rndebug_ip);
        no = (EditText)findViewById(R.id.rndebug_no);
        webBackView = findViewById(R.id.web_back);

        pageName = (TextView) findViewById(R.id.rndebug_page);
        ClickUtils.setFastOnClickListener(webBackView, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        findViewById(R.id.debug_test).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserInfoConstants.DominNo = 1;
                finish();
            }
        });
        findViewById(R.id.debug_t1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserInfoConstants.DominNo = 2;
                finish();
            }
        });
        findViewById(R.id.debug_spare).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserInfoConstants.DominNo = 3;
                finish();
            }
        });
        findViewById(R.id.debug_api).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UserInfoConstants.DominNo = 4;
                finish();
            }
        });

        findViewById(R.id.rndebug_login).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settingDebug(0);
            }
        });
        findViewById(R.id.rndebug_home).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settingDebug(1);
            }
        });
        findViewById(R.id.rndebug_message).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settingDebug(2);
            }
        });
        findViewById(R.id.rndebug_cart).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settingDebug(3);
            }
        });
        findViewById(R.id.rndebug_mine).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settingDebug(4);
            }
        });


        findViewById(R.id.rndebug_open1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppReactUtils.INSTANCE.push(DebugRnActivity.this, KitArouterConstants.LOGIN_DOCTORBUNDLE,pageName.getText().toString().trim());
            }
        });
        findViewById(R.id.rndebug_open2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppReactUtils.INSTANCE.push(DebugRnActivity.this,KitArouterConstants.HOME_DOCTORBUNDLE,pageName.getText().toString().trim());
            }
        });
        findViewById(R.id.rndebug_open3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppReactUtils.INSTANCE.push(DebugRnActivity.this,KitArouterConstants.IM_DOCTORBUNDLE,pageName.getText().toString().trim());
            }
        });
        findViewById(R.id.rndebug_open4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppReactUtils.INSTANCE.push(DebugRnActivity.this,KitArouterConstants.CART_DOCTORBUNDLE,pageName.getText().toString().trim());
            }
        });
        findViewById(R.id.rndebug_open5).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AppReactUtils.INSTANCE.push(DebugRnActivity.this,KitArouterConstants.MY_BUNDLE,pageName.getText().toString().trim());
            }
        });

        findViewById(R.id.rndebug_open6).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                startActivity(new Intent(DebugRnActivity.this, ConversationGroupActivity.class));
//                ARouter.getInstance().build(ARouterConstants.MineWebviewActivity)
//                        .withString("title", "测试")
//                        .withString("url", "https://activity.d1.yilijk.com/index.html?t=1651754437#/cms/117?tk=eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIyMTczMTgyMjc2NDAzMjEiLCJ0eXBlIjoyLCJzb3VyY2UiOjkwMDIsImxvZ2luVHlwZSI6IjEiLCJ0aW1lIjoxNjUxNzQxNzA2NDg0fQ.vdqJn_-fRe494Z1pweo7vt2nHuakC2Nh_jU4pXH9Txg")
//                        .withBoolean("ishtml", false)
//                        .navigation();
//
//                AppReactUtils.INSTANCE.push(DebugRnActivity.this,KitArouterConstants.HOME_DOCTORBUNDLE,"DoctorHealth");

                ARouter.getInstance()
                        .build(ARouterConstants.Home.DoctorHealthActivity)
                        .withInt("id",17)
                        .navigation();
                finish();
            }
        });

        findViewById(R.id.rndebug_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                settingDebug(-1);
            }
        });

    }
    private String IP = "";
    private String NO = "";
    void settingDebug(int i) {
        IP = ip.getText().toString().trim();
        NO = no.getText().toString().trim();
        String DEBUGIP = IP+":"+NO;
        switch (i) {
            case -1:
            {
                RNDebugUtils.RNDebugModel debugModule = new RNDebugUtils.RNDebugModel(KitArouterConstants.LOGIN_DOCTORBUNDLE, DEBUGIP, false);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule);
                RNDebugUtils.RNDebugModel debugModule1 = new RNDebugUtils.RNDebugModel(KitArouterConstants.HOME_DOCTORBUNDLE, DEBUGIP, false);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule1);
                RNDebugUtils.RNDebugModel debugModule2 = new RNDebugUtils.RNDebugModel(KitArouterConstants.IM_DOCTORBUNDLE, DEBUGIP, false);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule2);
                RNDebugUtils.RNDebugModel debugModule3 = new RNDebugUtils.RNDebugModel(KitArouterConstants.CART_DOCTORBUNDLE, DEBUGIP, false);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule3);
                RNDebugUtils.RNDebugModel debugModule4 = new RNDebugUtils.RNDebugModel(KitArouterConstants.MY_BUNDLE, DEBUGIP, false);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule4);
            }
                break;
            case 0:
                RNDebugUtils.RNDebugModel debugModule = new RNDebugUtils.RNDebugModel(KitArouterConstants.LOGIN_DOCTORBUNDLE, DEBUGIP, true);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule);
                break;
            case 1:
                RNDebugUtils.RNDebugModel debugModule1 = new RNDebugUtils.RNDebugModel(KitArouterConstants.HOME_DOCTORBUNDLE, DEBUGIP, true);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule1);
                break;
            case 2:
                RNDebugUtils.RNDebugModel debugModule2 = new RNDebugUtils.RNDebugModel(KitArouterConstants.IM_DOCTORBUNDLE, DEBUGIP, true);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule2);
                break;
            case 3:
                RNDebugUtils.RNDebugModel debugModule3 = new RNDebugUtils.RNDebugModel(KitArouterConstants.CART_DOCTORBUNDLE, DEBUGIP, true);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule3);
                break;
            case 4:
                RNDebugUtils.RNDebugModel debugModule4 = new RNDebugUtils.RNDebugModel(KitArouterConstants.MY_BUNDLE, DEBUGIP, true);
                RNDebugUtils.setDebugStatus(DebugRnActivity.this, debugModule4);
                break;
        }
        finish();
    }

}